{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5688f69a",
   "metadata": {},
   "outputs": [],
   "source": [
    "from mltools import data as ma\n",
    "from PIL import Image\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "38b03b3f",
   "metadata": {},
   "outputs": [],
   "source": [
    "bbox = ma.read_txt_label_file(r\"../datasets/crack/labels/val/test_0000.txt\")\n",
    "print(bbox)\n",
    "bbox"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "288e7c51",
   "metadata": {},
   "outputs": [],
   "source": [
    "image = Image.open(r\"../datasets/crack/masks/001.png\")\n",
    "ma.mask_to_bbox(np.array(image))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "229e6c30",
   "metadata": {},
   "outputs": [],
   "source": [
    "image_dir_path = \"../datasets/crack/images/val\"\n",
    "label_dir_path = \"../datasets/crack/labels/val\"\n",
    "ma.batch_rename(image_dir_path, label_dir_path, prefix=\"val\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9c9ca7e3",
   "metadata": {},
   "outputs": [],
   "source": [
    "ma.batch_xml_to_txt(\"../datasets/RODD/Annotations\", \"../datasets/RODD/labels\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "mltools",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
